function print_tbl(tbl)
	print("**********table*************")
	for k, v in pairs(tbl) do
		print(k)
	end
	print("****************************")
end

function LoadModule(path)
	local e = string.len(path)
	local s = e - 1
	while s >= 1 do
		if string.byte(path, s) == string.byte('/') then -- 47 is '/'
			break
		end
		s = s - 1
	end

	local name = string.sub(path, s + 1, e)
	print("module: ", name, " from: ", path)
	local env = getfenv(0)
	if env[name] ~= nil then
		print("error: module %s already exists", name)
		return
	end
	local mod_env = {}
	local mod_meta_table = {}
	mod_meta_table["__index"] = env
	setmetatable(mod_env, mod_meta_table)
	env[name] = mod_env
	setfenv(0, mod_env)
	require(path)
	setfenv(0, env)
end

function Update()
	collectgarbage()
	ov.RenderOneFrame()
end

function RunEditor()
    LoadModule("script/editor")
	oveditor = editor.CreateEditor()
	oveditor:Run()
end

function RunGame()
    LoadModule("script/game")
    ovgame = game.CreateGame()
end

function Main()
	--RunEditor()
    RunGame()
end